/**
 * @file trasmitProcess.h
 * @brief 
 * @author xuesong (wenshaoliu@foxmail.com)
 * @version 1.0
 * @date 2023-06-17
 * 
 * @copyright Copyright (c) 2023  by xuesong
 * 
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version <th>Author  <th>Description
 * <tr><td>2023-06-17     <td>1.0     <td>xuesong   <td>内容
 * </table>
 */

#ifndef __TRASMIT_PROCESS_H__
#define __TRASMIT_PROCESS_H__

#include "bcomdef.h"
#include "ll_def.h"
#include "comdef.h"
#include  "error.h"
#include "streambuffer.h"
#include "bleuart_service.h"
#ifdef __cplusplus
extern "C"
{
#endif

#define TrasmitEvent_UART_RCV           0x0001
#define TrasmitEvent_UART_TX            0x0002
#define TrasmitEvent_Master_RCV         0x0004          //< F25 Commincate with slaver F25
#define TrasmitEvent_Master_TX          0x0008          //>
#define TrasmitEvent_Slaver_RCV         0x0010          //< F25 Commincate with app
#define TrasmitEvent_Slaver_TX          0x0020          //>
//----------------------------------------------------------------
typedef enum 
{
	CMD_ERROR		,		//命令错误（长度错误 或 无命令）
	CMD_SET_TIME    ,
	CMD_READ_BATCAP ,
	CMD_START_FJ    ,			//3,1启动自由跳
	CMD_START_DT    ,			//3,2启动倒计时
	CMD_START_DC    ,			//3,3启动倒计数			
	CMD_MD_SUSPEND  ,		    //3,4暂停
	CMD_MD_RECOVERY ,		    //3,5 If use 'cmd_suspend' ,recovery the now mode
	CMD_MD_STOP     ,			//3.6
	CMD_SYN_HISTORY ,		    //3.7
	CMD_SYN_END     ,			//3.8
	CMD_READ_INFO   ,			//4，0
	CMD_DIRECTE_DAT ,			//非蓝牙主机处理过数据
}HuaweiCmdDef;
//----------------------------------------------------------------
typedef struct
{
    uint8_t type;
    uint8_t len;
    uint8_t *data;
}tlv_t;
typedef struct
{
    uint8_t head;
    uint8_t sourceAddr;
    uint8_t destinationAddr;
}headSD_t;

typedef enum
{
   DeviceAddr_Rope      = 0x01,      //跳绳
   DeviceAddr_MulitPack,             //显示包 蓝牙
   DeviceAddr_LedDisplay,            //1248 LED显示
   DeviceAddr_MulitCApp,             //多主从端连接蓝牙部分
}DeviceAddr;

typedef enum
{
   DeviceCmd_Sleep  = 0x20,         //sleep
   DeviceCmd_Status  = 0x21,        //status
}DeviceCmd;

#define TrasmitEvent_Head          0xA5          //>
//----------------------------------------------------------------
extern uint8_t Trasmit_TaskID;

extern StreamBufferDef xStreamUartRx;
extern StreamBufferDef xStreamUartTx;
//----------------------------------------------------------------
void TrasmitPrcess_Init(uint8 task_id);
uint16 Trasmit_ProcessEvent(uint8 task_id, uint16 events);
void Transmit_task_set(uint8 action, uint16 event, uint32 time);
void ble_data_rec_evt(ble_data_evt_t* pev);
void NotifySlaverMasterStatus(void);
#ifdef __cplusplus
}
#endif

#endif

